﻿using System;
using System.Windows;
using System.Windows.Data;

namespace mal.WP7.Framework.Converters
{
    public class BoolToVisibilityConverter: IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool visibility = (bool)value;

            string inverse = string.Empty;
            if (parameter != null)
                inverse = parameter.ToString();

            if (inverse.ToLower() =="inverse")
                visibility = !visibility;

            if (visibility)
                return Visibility.Visible;
            else
                return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
  
}
